<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="http://www.kuibutech.com/wechatAuth/css/weui.css">
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

    <title>打卡分享</title>
</head>

<style type="text/css">
    body {
        margin: 0px;
        background-color: #FAFAFA;
    }

    .head {
        position: fixed;
        left: 0px;
        top: 0px;
        background-color: #ffffff;
        width: 100%;
        height: 2.6rem;
        vertical-align: middle;
        filter: alpha(Opacity=20);
        -moz-opacity: 0.8;
        opacity: 0.8;
        z-index: 100;
    }

    .user-bg {
        background-image: url("http://kuibutech.oss-cn-shanghai.aliyuncs.com/reevesFiles/kaixueji.jpg");
        width: 100%;
        height: 11.5rem;
        text-align: center;
    }

    .user {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        border: solid 2px #ffffff;
        overflow: hidden;
        margin-top: 60px;
    }

    .content {
        margin-top: 0rem;
        width: 90%;
        margin-left: 2%;
        padding: 10px 10px;
        background-color: #ffffff;
        margin-bottom: 50px;
    }

    .other {
        font-size: 13px;
        margin-top: 20px;
    }

    .cancel {
        margin-top: 20px;
        margin-bottom: 15px;
        font-size: 10px;
        float: right;
        color: #5A5A5A;
    }

    .ad {
        width: 90%;
        margin-left: 5%;
        margin-bottom: 60px;
    }

    .pic img {
        width: 100%;
        height: 400px;
        margin-bottom: 5px;
    }
</style>

<script type="text/javascript">
    function comfirmDeleteRecord() {
        location.href = "/wechatAuth/route/gotoMain";
    }

    function deleteRecord() {
        var launchCardId = ${launchCardId};
        $.post("/wechatAuth/launchcard/deleteRecord", {launchId: launchCardId}, function (data) {
            if (data.result == true) {
                $('#dialog').show();
            }
        });
    }

    $(document).ready(function () {
        var shareLink = "http://www.kuibutech.com/wechatAuth/share/page/" + ${userId} +"-" + ${launchCardId};
        var link = "http://www.kuibutech.com/wechatAuth/route/gotoShare/" +${launchCardId};

        $.post("http://www.kuibutech.com/wechatAuth/wechat/getSignature", {url: link}, function (data, status) {
            wx.config({
                debug: false,
                appId: 'wx651efc7e955f2b3c',
                timestamp: data.timeStamp,
                nonceStr: 'haoransun',
                signature: data.signature,
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone'
                ]
            });
            wx.ready(function () {

                // 分享到朋友圈
                wx.onMenuShareTimeline({
                    title: "今天我又为山区孩子献出了一份爱 | 让运动更有价值！", // 分享标题
                    desc: "来自燃烧21",
                    link: shareLink, // 分享链接
                    imgUrl: $("#user").attr("src"), // 分享图标
                    success: function (res) {
                        console.error(res);
                        // 这里放分享成功的回调函数
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                        console.error("error");
                    }
                });

                // 发送给朋友
                wx.onMenuShareAppMessage({
                    title: "今天我又为山区孩子献出了一份爱 | 让运动更有价值！", // 分享标题
                    desc: "来自燃烧21", // 分享描述
                    link: shareLink, // 分享链接
                    imgUrl: $("#user").attr("src"), // 分享图标
                    type: '', // 分享类型,music、video或link，不填默认为link
                    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                    success: function () {
                        // 用户确认分享后执行的回调函数
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });

                wx.onMenuShareQQ({
                    title: "今天我又为山区孩子献出了一份爱 | 让运动更有价值！", // 分享标题
                    desc: "来自燃烧21", // 分享描述
                    link: shareLink, // 分享链接
                    imgUrl: $("#user").attr("src"), // 分享图标
                    success: function () {
                        // 用户确认分享后执行的回调函数
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });

                wx.onMenuShareWeibo({
                    title: "今天我又为山区孩子献出了一份爱 | 让运动更有价值！", // 分享标题
                    desc: "来自燃烧21", // 分享描述
                    link: shareLink, // 分享链接
                    imgUrl: $("#user").attr("src"), // 分享图标
                    success: function () {
                        // 用户确认分享后执行的回调函数
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });

                wx.onMenuShareQZone({
                    title: "今天我又为山区孩子献出了一份爱 | 让运动更有价值！", // 分享标题
                    desc: "来自燃烧21", // 分享描述
                    link: shareLink, // 分享链接
                    imgUrl: $("#user").attr("src"), // 分享图标
                    success: function () {
                        // 用户确认分享后执行的回调函数
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });

            });
        });
    });
</script>

<body>
<div class="head">
    <div style="float: left;width: 33%;margin-top: 10px">
        <a href="javascript:history.back()"
           style="color: #04BE02;font-size: 17px;margin-left: 15px">返回</a>
    </div>
    <div style="float: left;width: 33%;text-align: center;margin-top: 10px">
        <label id="title" style="">打卡分享</label>

    </div>
    <div style="float: left;width: 33%;margin-top: 10px;text-align: right">
        <a href="/wechatAuth/route/gotoMain" style="color: #04BE02;font-size: 17px;margin-right: 13px">主页</a>
    </div>
</div>

<div class="user-bg">
    <img id="user" class="user" src="${user_info.photo}"/>
    <p style="color: #ffffff">${user_info.name}</p>
</div>

<div class="content">
    <div class="text">
        <p style="font-size: 18px;font-weight: 400;margin-bottom: 10px">
            <c:if test="${launch_info.type=='跑步'||launch_info.type=='骑行'}">
                ${launch_info.date}&nbsp;我跑了${launch_info.value}公里,为山区孩子捐献了2分钱,继续加油!
            </c:if>

            <c:if test="${launch_info.type=='走路'}">
                ${launch_info.date}&nbsp;我走了${launch_info.value}步,为山区孩子捐献了2分钱,继续加油!
            </c:if>

            <c:if test="${launch_info.type=='健身'||launch_info.type=='其他'}">
                ${launch_info.date}&nbsp;我运动了${launch_info.value}小时,为山区孩子捐献了2分钱,继续加油!
            </c:if>

        </p>
        <p style="font-size: 14px;color: #5A5A5A">运动心情：${launch_info.text}</p>
    </div>

    <div class="other">
        <a style="color: #00C000" href="">天气.${launch_info.weather}</a>
        <label style="float: right;margin-right: 10px">${launch_info.date} 分享于燃烧21</label>
    </div>

    <div class="cancel">
        <span onclick="javascript:deleteRecord()" style="color: #5A5A5A">取消打卡</span>
    </div>

    <hr style="width: 100%;margin-bottom:20px;height:1px;border:none;border-top:1px dashed #5A5A5A;"/>

    <div class="pic">
        <c:forEach items="${imgs}" var="photo">
            <c:if test="${photo!=''}"><img src="${photo}"></c:if>
        </c:forEach>
    </div>

</div>


<div hidden class="weui_dialog_alert" id="dialog">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">取消打卡成功</strong></div>
        <div class="weui_dialog_bd"></div>
        <div class="weui_dialog_ft">
            <a href="javascript:comfirmDeleteRecord()" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>


<div class="ad">
    <img style="width: 100%;height: 150px" src="http://kuibutech.oss-cn-shanghai.aliyuncs.com/reevesFiles/kaixueji.jpg">
</div>

</body>
</html>